import { ElNotification, ElMessage, ElMessageBox } from "element-plus";
import nProgress from "nprogress";
import moment from "moment";

// 提示
export function toast(msg, type = "success") {
  ElNotification({
    message: msg,
    type: type,
    offset: 150,
    duration: 3000,
  });
}

// 消息
export function message(msg, type = "success") {
  ElMessage({
    message: msg,
    type: type,
  });
}

// 消息弹框
export function messageBox(content,type = "warning",title = ""){
  return ElMessageBox.confirm(
    content,
    title,
    {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: type,
    }
  );
}

// 显示全局loading
export function showFullLoading(){
  nProgress.start()
}

// 隐藏全局loading
export function hideFullLoading(){
  nProgress.done()
}

// 格式化时间
export function formatDate(dateStr){
  return moment(dateStr).format('YYYY-MM-DD HH:mm:ss')
}